/*******************************************************************************
 * This file is part of blueprint4j www.blueprint4j.org.
 * 
 *     blueprint4j is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU Lesser General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 * 
 *     blueprint4j is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU Lesser General Public License for more details.
 * 
 *     You should have received a copy of the GNU Lesser General Public License
 *     along with blueprint4j. If not, see <http://www.gnu.org/licenses/>.
 ******************************************************************************/
package blueprint4j.utils;

import java.io.*;
import java.util.*;

public class LoggingMixer extends Logging {
	Vector logs=new Vector();

	public LoggingMixer(boolean debug, boolean trace, boolean critical) {
		super(debug, trace, critical);
	}

	public void addLogging(Logging log){
		logs.add(log);
	}

	public void write(String level,long thread_id,String description, String details){
		for (int t=0;t<logs.size();t++){
			((Logging)logs.get(t)).write(level,thread_id,description,details);
		}
	}

	/**
	 * Build logs from all the Loggers and renove the duplicates
	 */
	public LogDataUnitVector findLogs(Integer tid,java.util.Date from_date,java.util.Date to_date,Logging.Level levels[])
	throws IOException {
		LogDataUnitVector log_data_units = new LogDataUnitVector();
		int size = 0;
		for (int t=0;t<logs.size();t++){
			LogDataUnitVector v_log_data_units = ((Logging)logs.get(t)).findLogs(tid,from_date,to_date,levels);
			log_data_units.add(v_log_data_units);
		}
		return log_data_units;
	}

	/*
	public void writeTrace(String description, String details){
		for (int t=0;t<logs.size();t++){
			((Logging)logs.get(t)).writeTrace(description,details);
		}
	}

	public void writeDebug(String description, String details){
		for (int t=0;t<logs.size();t++){
			((Logging)logs.get(t)).writeDebug(description,details);
		}
	}

	public void writeCritical(String description, String details){
		for (int t=0;t<logs.size();t++){
			((Logging)logs.get(t)).writeCritical(description,details);
		}
	}*/

	public void close(){
		for (int t=0;t<logs.size();t++){
			((Logging)logs.get(t)).close();
		}
	}
}

